package com.meida.boot.handler;

import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.interceptor.GetInterceptor;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.file.provider.service.SysFileService;
import com.meida.module.product.client.entity.ProdProduct;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 产品详细信息处理器
 */
@Component("productDetailsHandler")
@Log4j2
public class ProductDetailsHandler implements GetInterceptor {

    @Autowired
    private SysFileService fileService;

    /**
     * 查询条件扩展
     *
     * @param cq
     * @return
     */
    @Override
    public void prepare(CriteriaQuery cq, EntityMap params) {

    }


    /**
     * 返回结果集扩展
     *
     * @param cq
     * @return
     */
    @Override
    public void complete(CriteriaQuery cq, EntityMap map) {
        Long productId = map.getLong("productId");
        List<EntityMap> fileList = fileService.selectFileList(productId, ProdProduct.class);
        map.put("fileList", fileList);
    }
}
